import React, { useState } from 'react';
import { useLocation, useNavigate } from 'umi';
import { message } from 'antd';
import { Row, Col, Divider, Card, Form, Input, Button } from 'antd';

const RedirectPage = () => {
  const [password, setPassword] = useState('');
 
  
  const handleSubmit = async () => {
    console.log(password,'1111111')
    // try {
    //   const response = await request('/api/validate-password', {
    //     method: 'POST',
    //     data: { shortLink, password },
    //   });

    //   if (response.valid) {
    //     navigate(response.targetPath, { replace: true }); // 跳转到目标页面
    //   } else {
    //     message.error('密码错误，请重试！');
    //   }
    // } catch (error) {
    //   console.error('验证失败', error);
    //   message.error('验证失败，请稍后再试。');
    // }
  };

  return (
    <div style={{height:'100%', display:'flex', justifyContent:'center',flexDirection:'column'}}>
       <Row justify="center">
          <Col span={10} >
              <Card>
                  <h3>请输入访问密码</h3>
                  <Form
                      name="basic"
                      autoComplete="off"
                  >

                      <Form.Item
                      label="Password"
                      name="password"
                      rules={[{ required: true, message: '请输入密码！' }]}
                      >
                      <Input.Password />
                      </Form.Item>
                  </Form>
                  <Divider />
                  <Button type="primary" style={{float:'right'}} onClick={handleSubmit}>继续访问</Button>
              </Card>
          </Col>
      </Row>
    </div>
  );
};

export default RedirectPage;